/**
*@param e //传来的所需上传图片的url
**/
function UPIMGs(e) {
    console.log(e)
    return new Promise((resolve, reject) => {

        var COS = require('cos-js-sdk-v5');

        var cos = new COS({
            SecretId: 'AKIDzpOimZ5QUHn21i8H9k47tOcZFemcBTUE',
            SecretKey: 'TgcHekZ7ICqCH5dtsa1B4g04rMbZGgof'
        });
        var len = 15;
        var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
        var maxLen = $chars.length;
        var str = '';
        for (var i = 0; i < len; i++) {
            str += $chars.charAt(Math.floor(Math.random() * maxLen));
        }
        this.nowTime = Date.parse(new Date());
        var newTime = this.nowTime / 1000;

        const filename = str + newTime;
        cos.putObject(
            {
                //上传对象
                Bucket: 'futurestar-1312936217',
                Region: 'ap-shanghai',
                Key: filename, //上传的名字
                StorageClass: 'STANDARD',
                Body: e, // 上传文件对象
                onProgress: function (progressData) { }
            },
            (err, data) => {
                console.log(data);
                var qq = 'https://' + data.Location;
                resolve(qq)

            }
        );

    })
}
export default UPIMGs;
